package com.zjw.entity;

import com.zjw.utils.Constants;

public class Page {
    private int totalPageCount;   //总页数
    private int pageSize = Constants.DEFAULT_PAGE_SIZE; //每页展示记录数
    private int totalCount;  //记录总数
    private int currPageNo = Constants.START_PAGE_NUM; //当前页码

    public int getCurrPageNo() {
        if (totalPageCount == 0) {
            return 0;
        }
        return currPageNo;
    }

    public void setCurrPageNo(int currPageNo) {
        if (currPageNo >= Constants.START_PAGE_NUM) {
            this.currPageNo = currPageNo;
        }
        if (currPageNo > totalPageCount){
            this.currPageNo = totalPageCount;
        }
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        if (pageSize > 0) {
            this.pageSize = pageSize;
        }
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        if (totalCount > 0) {
            this.totalCount = totalCount;
            //计算总页数
            totalPageCount = this.totalCount % pageSize == 0 ?
                    (this.totalCount / pageSize) : (this.totalCount / pageSize + 1);
        } else {
            totalPageCount = 1;
        }
    }

    public int getTotalPageCount() {
        return totalPageCount;
    }

    public void setTotalPageCount(int totalPageCount) {
        this.totalPageCount = totalPageCount;
    }


}
